package demo1;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class TestDemo1 {

    //输入流 --- inputStream
    //从文件中读取
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("text.txt")){
            byte[] bytes = new byte[1024];
            while(true){
                int len  = inputStream.read(bytes);
                if(len==-1){
                    break;
                }
                for(int i =0;i<len;++i){
                    System.out.printf("%c",bytes[i]);
                }
            }
            inputStream.close();
        }catch(IOException e){
            e.printStackTrace();
        }
    }

}
